package com.wl.feign;

import com.wl.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component//交给spring管理
public class UserFeignFallbackFactory implements FallbackFactory<UserFeign> {
    @Override
    public UserFeign create(Throwable throwable) {
        //打印错误
        throwable.printStackTrace();
        return new UserFeign() {
            @Override
            public User getById(Long id) {
                return new User(-1L,"触发熔断","GG");
            }
        };
    }
}
